package com.manli.wechat.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.manli.common.utils.HttpUtil;
import com.manli.wechat.pojo.*;

import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *微信卡券
 */
public class WeChatCardTicket extends WeChat{

    public WeChatCardTicket(String appid, String appsecret) {
        super(appid, appsecret);
    }

    public static void main(String[] args)throws Exception {
        WeChatCardTicket weChatCardTicket = new WeChatCardTicket("wx6f56d14c68184b2f","3f0ba2c566ac7d3365ceaea2ae0bd223");

        String token = "36_FxpxrRqNPVpSHQA0Zc7YgAMPwGFJINBuf_10KvGhYhD8lP34HO3AsrXAzuPQ97C2JF0jEAOioMsc31y6Bejh-DJX00sR1jXFa6G5mS235gaV-EBkoQblkE7JP8j0pkgzVY7In_qn__BCUHWPEHRfAIAHKU";
//        File file = new File("C:\\Users\\fjc\\Desktop\\uugai.com_1586003734742.jpg");
//
//        uploadImg(token,file,"buffer");

        //创建卡券
//        WeChatCardTicketAborn<WeChatCardTicketGroupOn> weChatCardTicket1 = new WeChatCardTicketAborn();
//        WeChatCardTicketGroupOn groupOn = new WeChatCardTicketGroupOn();
//        groupOn.setCard_type(WeChatCardType.GROUPON);


//        WeChatCardTicketAborn<WeChatCardTicketCash> weChatCardTicket1 = new WeChatCardTicketAborn();
//        WeChatCardTicketCash cardTicketCash = new WeChatCardTicketCash();
//        cardTicketCash.setCard_type(WeChatCardType.CASH);
//        WeChatCash weChatCash = new WeChatCash();
//        WeChatCardBaseInfo weChatCardBaseInfo = new WeChatCardBaseInfo();
//        weChatCardBaseInfo.setLogo_url("http://mmbiz.qpic.cn/mmbiz/iaL1LJM1mF9aRKPZJkmG8xXhiaHqkKSVMMWeN3hLut7X7hicFNjakmxibMLGWpXrEXB33367o7zHN0CwngnQY7zb7g/0");
//        weChatCardBaseInfo.setBrand_name("漫狸科技");
//        weChatCardBaseInfo.setCode_type(WeChatCodeType.CODE_TYPE_TEXT);
//        weChatCardBaseInfo.setTitle("1元代金券");
//        weChatCardBaseInfo.setColor("Color010");
//        weChatCardBaseInfo.setNotice("使用时向服务员出示此券");
//        weChatCardBaseInfo.setService_phone("15708008000");
//        weChatCardBaseInfo.setDescription("不可与其他优惠同享\\n如需团购券发票，请在消费时向商户提出\\n");
//        WeChatCardDateInfo weChatCardDateInfo = new WeChatCardDateInfo();
//        weChatCardDateInfo.setType(WeChatCardDateType.DATE_TYPE_FIX_TERM);
////        weChatCardDateInfo.setBegin_timestamp(1586247000L);
////        weChatCardDateInfo.setEnd_timestamp(1586333400L);
//        weChatCardDateInfo.setFixed_begin_term(0);
//        weChatCardDateInfo.setFixed_term(1);
//        weChatCardBaseInfo.setDate_info(weChatCardDateInfo);
//        weChatCardBaseInfo.setUse_limit(100);
//        weChatCardBaseInfo.setGet_limit(1);
//        weChatCardBaseInfo.setUse_custom_code(false);
//        weChatCardBaseInfo.setBind_openid(false);
//        weChatCardBaseInfo.setCan_share(true);
//        weChatCardBaseInfo.setCan_give_friend(true);
//        weChatCardBaseInfo.setLocation_id_list(new ArrayList<>());
//        weChatCardBaseInfo.setCenter_title("顶部居中按钮");
//        WeChatCardSku weChatCardSku = new WeChatCardSku();
//        weChatCardSku.setQuantity(100);
//        weChatCardBaseInfo.setSku(weChatCardSku);
//
//        weChatCash.setBase_info(weChatCardBaseInfo);
//        WeChatCardAdvancedInfo weChatCardAdvancedInfo = new WeChatCardAdvancedInfo();
//
//        WeChatCardUseCondition useCondition = new WeChatCardUseCondition();
//        useCondition.setAccept_category("吃饭");
//        useCondition.setReject_category("停车");
//        useCondition.setCan_use_with_other_discount(true);
//        weChatCardAdvancedInfo.setUse_condition(useCondition);
//
//        WeChatCardAbstract chatCardAbstract = new WeChatCardAbstract();
//        chatCardAbstract.setAbstract1("微信餐厅推出多种新季菜品，期待您的光临");
//        ArrayList list = new ArrayList<String>();
//        list.add("http://mmbiz.qpic.cn/mmbiz/p98FjXy8LacgHxp3sJ3vn97bGLz0ib0Sfz1bjiaoOYA027iasqSG0sjpiby4vce3AtaPu6cIhBHkt6IjlkY9YnDsfw/0");
//        chatCardAbstract.setIcon_url_list(list);
//        weChatCardAdvancedInfo.setAbstract1(chatCardAbstract);
//        List<WeChatCardTextImage> images = new ArrayList<>();
//        WeChatCardTextImage image = new WeChatCardTextImage();
//        image.setText("此菜品精选食材，以独特的烹饪方法，最大程度地刺激食 客的味蕾");
//        image.setImage_url("http://mmbiz.qpic.cn/mmbiz/p98FjXy8LacgHxp3sJ3vn97bGLz0ib0Sfz1bjiaoOYA027iasqSG0sjpiby4vce3AtaPu6cIhBHkt6IjlkY9YnDsfw/0");
//        images.add(image);
//        WeChatCardTextImage image1 = new WeChatCardTextImage();
//        image1.setText("此菜品精选食材，以独特的烹饪方法，最大程度地刺激食 客的味蕾");
//        image1.setImage_url("http://mmbiz.qpic.cn/mmbiz/p98FjXy8LacgHxp3sJ3vn97bGLz0ib0Sfz1bjiaoOYA027iasqSG0sjpiby4vce3AtaPu6cIhBHkt6IjlkY9YnDsfw/0");
//        images.add(image1);
//        weChatCardAdvancedInfo.setText_image_list(images);
//
//        WeChatTimeLimit limit = new WeChatTimeLimit();
//        limit.setType(WeChatCardTimeType.FRIDAY);
//        limit.setBegin_hour(0);
//        limit.setEnd_hour(24);
//        limit.setBegin_minute(0);
//        limit.setEnd_minute(10);
//
//        WeChatTimeLimit limit1 = new WeChatTimeLimit();
//        limit1.setType(WeChatCardTimeType.TUESDAY);
//        limit1.setBegin_hour(0);
//        limit1.setEnd_hour(24);
//        limit1.setBegin_minute(0);
//        limit1.setEnd_minute(10);
//
//        List<WeChatTimeLimit> limits = new ArrayList<>();
//        weChatCardAdvancedInfo.setTime_limit(limits);
//
//        List<WeChatCardBusinessServiceType> serviceTypes = new ArrayList<>();
//        serviceTypes.add(WeChatCardBusinessServiceType.BIZ_SERVICE_FREE_WIFI);
//        weChatCardAdvancedInfo.setBusiness_service(serviceTypes);
//        weChatCash.setAdvanced_info(weChatCardAdvancedInfo);
//        weChatCash.setLeast_cost(0);
//        weChatCash.setReduce_cost(100);
//
//        cardTicketCash.setCash(weChatCash);
//
////        WeChatGroupOn weChatGroupOn = new WeChatGroupOn();
////        WeChatCardBaseInfo weChatCardBaseInfo = new WeChatCardBaseInfo();
////        weChatCardBaseInfo.setLogo_url("http://mmbiz.qpic.cn/mmbiz/iaL1LJM1mF9aRKPZJkmG8xXhiaHqkKSVMMWeN3hLut7X7hicFNjakmxibMLGWpXrEXB33367o7zHN0CwngnQY7zb7g/0");
////        weChatCardBaseInfo.setBrand_name("漫狸餐厅");
////        weChatCardBaseInfo.setCode_type(WeChatCodeType.CODE_TYPE_TEXT);
////        weChatCardBaseInfo.setTitle("漫狸火锅");
////        weChatCardBaseInfo.setColor("Color010");
////        weChatCardBaseInfo.setNotice("使用时向服务员出示此券");
////        weChatCardBaseInfo.setService_phone("15708008000");
////        weChatCardBaseInfo.setDescription("不可与其他优惠同享\\n如需团购券发票，请在消费时向商户提出\\n店内均可使用，仅限堂食");
////        WeChatCardDateInfo weChatCardDateInfo = new WeChatCardDateInfo();
////        weChatCardDateInfo.setType(WeChatCardDateType.DATE_TYPE_FIX_TERM);
//////        weChatCardDateInfo.setBegin_timestamp(1586247000L);
//////        weChatCardDateInfo.setEnd_timestamp(1586333400L);
////        weChatCardDateInfo.setFixed_begin_term(0);
////        weChatCardDateInfo.setFixed_term(1);
////        weChatCardBaseInfo.setDate_info(weChatCardDateInfo);
////        WeChatCardSku weChatCardSku = new WeChatCardSku();
////        weChatCardSku.setQuantity(100);
////        weChatCardBaseInfo.setSku(weChatCardSku);
////        weChatCardBaseInfo.setUse_limit(100);
////        weChatCardBaseInfo.setGet_limit(1);
////        weChatCardBaseInfo.setUse_custom_code(false);
////        weChatCardBaseInfo.setBind_openid(false);
////        weChatCardBaseInfo.setCan_share(true);
////        weChatCardBaseInfo.setCan_give_friend(true);
////        weChatCardBaseInfo.setLocation_id_list(new ArrayList<>());
////        weChatCardBaseInfo.setCenter_title("顶部居中按钮");
////
////        weChatGroupOn.setBase_info(weChatCardBaseInfo);
//
////        WeChatCardAdvancedInfo weChatCardAdvancedInfo = new WeChatCardAdvancedInfo();
////
////        WeChatCardUseCondition useCondition = new WeChatCardUseCondition();
////        useCondition.setAccept_category("鞋类");
////        useCondition.setReject_category("阿迪达斯");
////        useCondition.setCan_use_with_other_discount(true);
////        weChatCardAdvancedInfo.setUse_condition(useCondition);
////
////        WeChatCardAbstract chatCardAbstract = new WeChatCardAbstract();
////        chatCardAbstract.setAbstract1("微信餐厅推出多种新季菜品，期待您的光临");
////        ArrayList list = new ArrayList<String>();
////        list.add("http://mmbiz.qpic.cn/mmbiz/p98FjXy8LacgHxp3sJ3vn97bGLz0ib0Sfz1bjiaoOYA027iasqSG0sjpiby4vce3AtaPu6cIhBHkt6IjlkY9YnDsfw/0");
////        chatCardAbstract.setIcon_url_list(list);
////        weChatCardAdvancedInfo.setAbstract1(chatCardAbstract);
////        List<WeChatCardTextImage> images = new ArrayList<>();
////        WeChatCardTextImage image = new WeChatCardTextImage();
////        image.setText("此菜品精选食材，以独特的烹饪方法，最大程度地刺激食 客的味蕾");
////        image.setImage_url("http://mmbiz.qpic.cn/mmbiz/p98FjXy8LacgHxp3sJ3vn97bGLz0ib0Sfz1bjiaoOYA027iasqSG0sjpiby4vce3AtaPu6cIhBHkt6IjlkY9YnDsfw/0");
////        images.add(image);
////        WeChatCardTextImage image1 = new WeChatCardTextImage();
////        image1.setText("此菜品精选食材，以独特的烹饪方法，最大程度地刺激食 客的味蕾");
////        image1.setImage_url("http://mmbiz.qpic.cn/mmbiz/p98FjXy8LacgHxp3sJ3vn97bGLz0ib0Sfz1bjiaoOYA027iasqSG0sjpiby4vce3AtaPu6cIhBHkt6IjlkY9YnDsfw/0");
////        images.add(image1);
////        weChatCardAdvancedInfo.setText_image_list(images);
////
////        WeChatTimeLimit limit = new WeChatTimeLimit();
////        limit.setType(WeChatCardTimeType.FRIDAY);
////        limit.setBegin_hour(0);
////        limit.setEnd_hour(24);
////        limit.setBegin_minute(0);
////        limit.setEnd_minute(10);
////
////        WeChatTimeLimit limit1 = new WeChatTimeLimit();
////        limit1.setType(WeChatCardTimeType.TUESDAY);
////        limit1.setBegin_hour(0);
////        limit1.setEnd_hour(24);
////        limit1.setBegin_minute(0);
////        limit1.setEnd_minute(10);
////
////        List<WeChatTimeLimit> limits = new ArrayList<>();
////        weChatCardAdvancedInfo.setTime_limit(limits);
////
////        List<WeChatCardBusinessServiceType> serviceTypes = new ArrayList<>();
////        serviceTypes.add(WeChatCardBusinessServiceType.BIZ_SERVICE_FREE_WIFI);
////        weChatCardAdvancedInfo.setBusiness_service(serviceTypes);
////        weChatGroupOn.setAdvanced_info(weChatCardAdvancedInfo);
////        weChatGroupOn.setDeal_detail("漫狸测试");
////        groupOn.setGroupon(weChatGroupOn);
////        weChatCardTicket1.setCard(groupOn);
//
//        weChatCardTicket1.setCard(cardTicketCash);
//        createCard(token,weChatCardTicket1);

        //发券二维码
        WeChatCardCreateQrCode weChatCardCreateQrCode = new WeChatCardCreateQrCode();
        weChatCardCreateQrCode.setAction_name(WeChatCardCreateQrCodeType.QR_CARD);
        weChatCardCreateQrCode.setExpire_seconds(1800);
        WeChatCardActionInfo weChatCardActionInfo = new WeChatCardActionInfo();
        WeChatCardActionInfoCard weChatCardActionInfoCard = new WeChatCardActionInfoCard();
        weChatCardActionInfoCard.setCard_id("pJRQnwi8Wk4YspXpG0YXrts8HBZE");
//        weChatCardActionInfoCard.setOpenid("oJRQnwpKgeQnlal-xp72MLmGo7Jg");
        weChatCardActionInfoCard.setOpenid("oJRQnwvbiRCQGmw6xzMsBCme2ILg");
        weChatCardActionInfoCard.setOuter_str("1");
        weChatCardActionInfo.setCard(weChatCardActionInfoCard);
        weChatCardCreateQrCode.setAction_info(weChatCardActionInfo);
        cardidTransQrCodeTicket(token,weChatCardCreateQrCode);

        //获取卡券code
//        WeChatCardQuery weChatCardQuery = new WeChatCardQuery();
//        weChatCardQuery.setCard_id("pXzMAwIIDiUzjFesgB_7dkK6d5vM");
//        cardQueryByCode(token,weChatCardQuery);

    }

    /**
     * 微信卡券
     * 上传图片接口
     * 文件的数据流key value 对应的名字。即表单的name，例如acceccToken：xxxxxxx
     * @return
     */
    public JSONObject uploadImg(String acceccToken, File file,String name) throws Exception{
        isInited();
        if(file.length() > 1048576){
            throw new RuntimeException("FILE SIZE GREATER THAN 1MB.");
        }
        String fileName = file.getName();
        String suffix = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();

        if("jpg".equals(suffix) || "png".equals(suffix)) {
            return JSONObject.parseObject(HttpUtil.httpsPostImg(WeChatUrl.UPLOAD_IMG_URL + acceccToken,file,name));
        }else{
            throw new RuntimeException("FILE TYPE MUST BE JPG OR PNG.");
        }

    }

    /**
     * 微信卡券
     * 创建卡券
     * @return
     */
    public static JSONObject createCard(String acceccToken, WeChatCardTicketAborn card) throws Exception{
//        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.CARD_CREATE_URL + acceccToken,json,HttpUtil.JSON));


    }


    /**
     * 微信卡券
     * 卡券id换二维码以及ticket接口，扫描二维码领取单张卡券
     * @return
     */
    public static JSONObject cardidTransQrCodeTicket(String acceccToken, WeChatCardCreateQrCode card) throws Exception{
//        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.CARDID_TRANS_QRCODE_URL + acceccToken,json,HttpUtil.JSON));
    }


    /**
     * 微信卡券
     * 卡券id换二维码以及ticket接口，扫描二维码领取多张卡券
     * @return
     */
    public JSONObject cardidTransQrCodeTickets(String acceccToken, WeChatCardCreateQrCodes card) throws Exception{
        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.CARDID_TRANS_QRCODE_URL + acceccToken,json,HttpUtil.JSON));
    }

    /**
     * 微信卡券
     * 创建货架接口
     * @return
     */
    public JSONObject createCardList(String acceccToken, WeChatCardsList card) throws Exception{
        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.CREATE_CARD_LIST_URL + acceccToken,json,HttpUtil.JSON));
    }

    /**
     * 微信卡券
     * 获取卡券嵌入图文消息的标准格式代码,用于素材管理接口
     * @return
     */
    public JSONObject getCardHtml(String acceccToken, WeChatCard card) throws Exception{
        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.GET_CARD_HTML_URL + acceccToken,json,HttpUtil.JSON));
    }



    /**
     * 微信卡券
     * 设置卡券测试白名单
     * @return
     */
    public  JSONObject setCardWhiteList(String acceccToken, WeChatCardWhiteList card) throws Exception{
        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.CARD_WHITE_LIST_URL + acceccToken,json,HttpUtil.JSON));
    }

    /**
     * 微信卡券
     * 线下核销-查询code接口
     * @return
     */
    public static  JSONObject cardQueryByCode(String acceccToken, WeChatCardQuery card) throws Exception{
//        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.CARD_QUERY_BY_CODE_URL + acceccToken,json,HttpUtil.JSON));
    }

    /**
     * 微信卡券
     * 线下核销-核销Code接口，卡券核销
     * @return
     */
    public  JSONObject cardDestory(String acceccToken, WeChatCardDestory card) throws Exception{
        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.CARD_QUERY_BY_CODE_URL + acceccToken,json,HttpUtil.JSON));
    }

    /**
     * 微信卡券
     * 线上核销-Code解码接口
     * @return
     */
    public  JSONObject codeDecrypt(String acceccToken, WeChatEncryptCode card) throws Exception{
        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.CODE_DECRYPT_URL + acceccToken,json,HttpUtil.JSON));
    }

    /**
     * 管理卡券
     * 获取用户已领取卡券接口
     * @return
     */
    public  JSONObject queryUserCardList(String acceccToken, WeChatUserCardList card) throws Exception{
        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.QUERY_USER_CARD_LIST_URL + acceccToken,json,HttpUtil.JSON));
    }

    /**
     * 管理卡券
     * 查看卡券详情
     * @return
     */
    public  JSONObject queryCardInfo(String acceccToken, WeChatCard card) throws Exception{
        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.CARD_INFO_URL + acceccToken,json,HttpUtil.JSON));
    }

    /**
     * 管理卡券
     * 批量查询卡券列表
     * @return
     */
    public  JSONObject batchQueryCardInfo(String acceccToken, WeChatCardBatch card) throws Exception{
        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.CARDS_INFO_URL + acceccToken,json,HttpUtil.JSON));
    }

    /**
     * 管理卡券
     * 修改库存接口
     * @return
     */
    public  JSONObject updateCardStock(String acceccToken, WeChatCardStock card) throws Exception{
        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.UPDATE_CARDS_STOCK_URL + acceccToken,json,HttpUtil.JSON));
    }

    /**
     * 管理卡券
     * 更改Code接口，不做，不使用自定义code
     * @return
     */

    /**
     * 管理卡券
     * 删除卡券接口
     * @return
     */
    public  JSONObject delCard(String acceccToken, WeChatCard card) throws Exception{
        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.DEL_CARD_URL + acceccToken,json,HttpUtil.JSON));
    }

    /**
     * 管理卡券
     * 设置卡券失效接口
     * @return
     */
    public  JSONObject delCard(String acceccToken, WeChatCardUnavailable card) throws Exception{
        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.UNAVAILABLE_CARD_URL + acceccToken,json,HttpUtil.JSON));
    }

    /**
     * 管理卡券
     * 拉取卡券概况数据接口
     * @return
     */
    public  JSONObject queryCardData(String acceccToken, WeChatCardData card) throws Exception{
        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.CARD_DATA_URL + acceccToken,json,HttpUtil.JSON));
    }

    /**
     * 管理卡券
     * 获取免费券数据接口
     * @return
     */
    public  JSONObject queryFreeCardData(String acceccToken, WeChatCardFreeData card) throws Exception{
        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.CARD_FREE_DATA_URL + acceccToken,json,HttpUtil.JSON));
    }

    /**
     * 管理卡券
     * 拉取会员卡概况数据接口
     * @return
     */
    public  JSONObject querMemberCardData(String acceccToken, WeChatCardData card) throws Exception{
        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.CARD_MEMBER_DATA_URL + acceccToken,json,HttpUtil.JSON));
    }

    /**
     * 管理卡券
     * 拉取单张会员卡数据接口
     * @return
     */
    public  JSONObject querOneMemberCardData(String acceccToken, WeChatCardMemberData card) throws Exception{
        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.CARD_ONE_MEMBER_DATA_URL + acceccToken,json,HttpUtil.JSON));
    }

    /**
     * 管理卡券
     * 更改卡券信息接口
     * @return
     */
    public  JSONObject querOneMemberCardData(String acceccToken, WeChatCardTicketUpdate card) throws Exception{
        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.UPDATE_CARD_INFO_URL + acceccToken,json,HttpUtil.JSON));
    }

    /**
     * 管理卡券
     * 更新会员信息
     * 当会员持卡消费后，支持开发者调用该接口更新会员信息。会员卡交易后的每次信息变更需通过该接口通知微信，便于后续消息通知及其他扩展功能。
     * @return
     */
    public  JSONObject updateMemberCardData(String acceccToken, WeChatCardTicketUpdate card) throws Exception{
        isInited();
        JSONObject json = (JSONObject)JSON.toJSON(card);
        return JSONObject.parseObject(HttpUtil.httpsPost(WeChatUrl.UPDATE_MEMBER_CARD_URL + acceccToken,json,HttpUtil.JSON));
    }

}
